package com.lyz.anli;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 数字加解密 4位
 *  先加密：每位数加5，乘以10，数字反转
 *  要求能解密，打印加密与解密
 */
public class De6szjm {
    public static void main(String[] args) {
        int[] arr = new int[4];
        jiami(arr);
        jiemi(arr);
    }
    public static void jiami(int[] arr){
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            System.out.println("输入加密数字：");
            arr[i]=(scanner.nextInt()+5)*10;
        }
        daoxu(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void jiemi(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i]=(arr[i]/10)-5;
        }
        daoxu(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void daoxu(int[] arr){
        int a = 0;
        for (int i = 0; i < arr.length; i++) {
            a=arr[arr.length-i-1];
            arr[arr.length-i-1]=arr[i];
            arr[i]=a;
        }
    }
}